home *** CD-ROM | disk | FTP | other *** search
/ C!T ROM 3 / ct-rom iiib.zip / ct-rom iiib / WINDOWS / UTILITY / DESKTOP / CMAP / CSCRNSVR.CPP < prev    next >
C/C++ Source or Header  |  1994-05-08  |  2KB  |  109 lines

  1. //
  2. // Filename:    cscrnsvr.cpp
  3. //
  4. //
  5. /*
  6.  
  7. This is a screen saver which uses colormap animation, a simple technique
  8. to achieve seemingly complicated motion.  The entire source of this
  9. program is provided for your convenience.  If you find it useful, I'll
  10. appreciate if you'll send me $10.  Send the check to:
  11.  
  12. CMAP registration
  13. c/o: Sin-Yaw Wang
  14. 5878 W. Walbrook Dr.
  15. San Jose, CA 95129
  16.  
  17. You can also contact me at sinyaw@netcom.com.
  18.  
  19.  
  20. */
  21. #include <afxwin.h>
  22. #include "cscrnsvr.h"
  23.  
  24. void 
  25. CScreenSaverWindow::OnDestroy()
  26. {
  27.     PostQuitMessage(0);
  28. }
  29.  
  30. void 
  31. CScreenSaverWindow::OnMouseMove(UINT, CPoint)
  32. {
  33.     static BOOL fHere;
  34.     static POINT ptLast;
  35.     POINT ptCursor,ptCheck;
  36.  
  37.     if (!fHere) {
  38.         GetCursorPos (&ptLast);
  39.         fHere = TRUE;
  40.     } else {
  41.         GetCursorPos (&ptCheck);
  42.  
  43.                 if (ptCursor.x = ptCheck.x - ptLast.x) {
  44.                         if (ptCursor.x < 0) {
  45.                             ptCursor.x *= -1;
  46.             }
  47.                 }
  48.                 if (ptCursor.y = ptCheck.y - ptLast.y) {
  49.                         if (ptCursor.y < 0) {
  50.                             ptCursor.y *= -1;
  51.             }
  52.                    }
  53.                 if ((ptCursor.x + ptCursor.y) > THRESHOLD) {
  54.                         PostMessage(WM_CLOSE,0,0l);
  55.         }
  56.     } // end-if-else
  57. }
  58.  
  59. BOOL
  60. CScreenSaverWindow::OnSetCursor(CWnd *, UINT, UINT)
  61. {
  62.     SetCursor(NULL);
  63.  
  64.     return TRUE;
  65. }
  66.  
  67.  
  68. BEGIN_MESSAGE_MAP(CScreenSaverWindow, CFrameWnd)
  69.     ON_WM_DESTROY()
  70.     ON_WM_KEYDOWN()    
  71.     ON_WM_LBUTTONDOWN()
  72.     ON_WM_MBUTTONDOWN()
  73.     ON_WM_MOUSEMOVE()
  74.     ON_WM_RBUTTONDOWN()
  75.     ON_WM_SETCURSOR()
  76.     ON_WM_SYSKEYDOWN()
  77. END_MESSAGE_MAP()
  78.  
  79. void 
  80. CScreenSaverWindow::OnSysKeyDown(UINT, UINT, UINT)
  81. {
  82.     PostMessage(WM_CLOSE, 0, 0l);
  83. }
  84.  
  85. void 
  86. CScreenSaverWindow::OnKeyDown(UINT, UINT, UINT)
  87. {
  88.     PostMessage(WM_CLOSE, 0, 0l);
  89. }
  90.  
  91. void 
  92. CScreenSaverWindow::OnLButtonDown(UINT, CPoint)
  93. {
  94.     PostMessage(WM_CLOSE, 0, 0l);    
  95. }
  96.  
  97. void 
  98. CScreenSaverWindow::OnMButtonDown(UINT, CPoint)
  99. {
  100.     PostMessage(WM_CLOSE, 0, 0l);
  101. }
  102.  
  103. void 
  104. CScreenSaverWindow::OnRButtonDown(UINT, CPoint)
  105. {
  106.     PostMessage(WM_CLOSE, 0, 0l);
  107. }
  108.  
  109.